C# 自訂義搜尋控件


使用這個方法就可以更方便的搜尋需要的Controls

// 遞迴尋找控制項的方法
private Control FindControlByName(Control parentControl, string name)
{
    if (parentControl.Name == name)
    {
        return parentControl;
    }

    foreach (Control childControl in parentControl.Controls)
    {
        Control targetControl = FindControlByName(childControl, name);
        if (targetControl != null)
        {
            return targetControl;
        }
    }

    return null;
}
#C# #Winform







你可能感興趣的文章

用 Nest.js 開發 API 吧 (四) - Service

用 Nest.js 開發 API 吧 (四) - Service

延續上一篇:建立分頁元件與modal元件

延續上一篇:建立分頁元件與modal元件

[MTR04] W2 D14 練習四:請寫出一個叫做 star 的 function 並且接受一個參數 n,能回傳 n 個 *。

[MTR04] W2 D14 練習四:請寫出一個叫做 star 的 function 並且接受一個參數 n,能回傳 n 個 *。






留言討論